package cn.plushine.service;


import cn.plushine.mapper.BaseCustomerMapper;
import cn.plushine.mapper.BaseSupplierMapper;
import cn.plushine.pojo.Customer;
import cn.plushine.pojo.Supplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 客户信息
 */
@Service
public class BaseCustomerServiceImpl implements BaseCustomerService {

    @Autowired
    BaseCustomerMapper baseCustomerMapper;

    // 获取客户信息列表
    @Override
    public List<Customer> get(String input) {
        // 无论有无数据，直接返回即可
        return baseCustomerMapper.get(input);
    }

    // 添加客户信息
    @Override
    public int add(Customer customer) throws Exception {
        int addDB = baseCustomerMapper.add(customer);
        if (addDB != 0) {
            return addDB;
        }
        throw new Exception("添加客户信息失败！");
    }

    // 修改客户信息失败
    @Override
    public int modify(Customer customer) throws Exception {
        int modifyDB = baseCustomerMapper.modify(customer);
        if (modifyDB != 0) {
            return modifyDB;
        }
        throw new Exception("修改客户信息失败");
    }

    @Override
    public int delete(int id) throws Exception {
        int deleteDB = baseCustomerMapper.delete(id);
        if (deleteDB != 0) {
            return deleteDB;
        }
        throw new Exception("删除客户信息失败");
    }
}
